const { getProducts, deleteProducts, modifyProducts, addProducts,getProductsall } = require("../dao/modules/productsDao");
//获取保险数据
module.exports.getProducts = async function (params) {
    const data = await getProducts(params);
    // console.log(22,data);
        return{
            data,
            message:'数据获取成功',
            status:1
        }
}
//删除某个保险数据 by_id
module.exports.deleteProducts=async function(params){
    const data=await deleteProducts(params);
    if(data.nModified>0){
        return{
            data,
            message:'删除成功',
            status:1
        }
    }else{
        return{
         message:'删除失败',
         status:0
        }
    }
}
//修改某个产品的数据
module.exports.modifyProducts=async function(params){
    const data=await modifyProducts(params);
    if(data.nModified==1){
        return{
            data,
            message:'修改成功',
            status:1
        }
      }else{
        return{
            message:'修改失败',
            status:0
        }
      } 
}
//新增保险产品信息
module.exports.addProducts=async function(params){
    const data=await addProducts(params);
    if(data._id){
        return{
            data,
            message:'添加成功',
            status:1
        }
    }else{
        return{
           
            message:'添加失败',
            status:0
        }
    }
}
//获取全部数据
module.exports.getProductsall=async function(params){
    const data=await getProductsall(params);
        return data 
}